

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*, java.sql.*, connection.*"%>
<%
/* 
<td >
<input type="text" name="name" value=""></td>
<td ><input type="text" name="latitude" value=""></td>
		  <td ><input type="text" name="longitude" value=""></td>
		  <td ><input type="text" name="description" value=""></td>
		  */
	Connection conn = new DbConnection().getConn();
	String name = request.getParameter("name");
	String id = request.getParameter("pollid");
	String delete= request.getParameter("delete");
	String text = request.getParameter("text");
	String type = request.getParameter("type");
	String color = request.getParameter("color");
	String Font = request.getParameter("font");
	String FontSize = request.getParameter("fontsize");
	String chartStyle = request.getParameter("chartStyle");
	String ChartColor = request.getParameter("chartColor");
	String Timer = request.getParameter("timer");
	String CAI = request.getParameter("CAI");
	String ResCounter = request.getParameter("ResCounter");
	String Correct1 = request.getParameter("Correct1");
	String Correct2 = request.getParameter("Correct2");
	String Correct3 = request.getParameter("Correct3");
	String Correct4 = request.getParameter("Correct4");
	String Correct5 = request.getParameter("Correct5");
	
	String sql;
	if(delete != null){
		sql = "INSERT INTO Question(Text, Type, Status, Font, Color, FontSize, ChartStyle, ChartColor, Timer, CurrentTimer, ResCounter, CAI, Correct1, Correct2,Correct3,Correct4,Correct5,"+ 
				"Highest, Lowest, TemplateQuestion, NumberOnly, NumberOfAnswer) VALUES ("+
						"'"+text+"', "+
						"'"+type+"', "+
						"0, "+
						"'"+Font+"', "+
						"'"+color+"', "+
						FontSize+", "+
						"'"+chartStyle+"', "+
						"'"+ChartColor+"', "+
						Timer+", "+
						Timer+", "+//curretTimer set to max to begin with
						"'"+ResCounter+"', "+
						"'"+CAI+"', "+
						"'"+Correct1+"', "+
						"'"+Correct2+"', "+
						"'"+Correct3+"', "+
						"'"+Correct4+"', "+
						"'"+Correct5+"', "+
						Highest+", "+
						Lowest+", "+
						"'"+TemplateQuestion+"', "+
						NumberOnly+", "+
						NumberofAnswer+", "+
						")";
	}
	System.out.println("SQL: "+sql);
	if(sql != null){
		try{
			PreparedStatement ps = conn.prepareStatement(sql);
			ps.executeQuery();
		
			response.sendRedirect("addQuestions.jsp?fail=false&pollid="+pollid+"&pollname="+name);
		}catch(SQLException e){
		 System.out.println(e);
		 response.sendRedirect("newPoll.jsp?fail=true");
		}
	}
	%>